package com.flute.framework.autoprompt;

public class TrieTree {
	private TrieNode root;

	public TrieTree() {
		this.root = new TrieNode();
	}

	public void addResult(String string, WordResult result) {
		root.addResult(string, result);
	}

	public WordResult find(String string) {
		char[] cs = string.toCharArray();
		TrieNode node = root;
		for (int i = 0; i < cs.length - 1; i++) {
			if (node.containsChild(cs[i])) {
				node = node.getChildNode(cs[i]);
			} else {
				return null;
			}
		}

		return node.getResult();
	}
}
